const Router = require('@koa/router');
const { serviceUrl, port } = require('../config/app');
const router = new Router({
  prefix: '/api/v1/file'
})

router.post('/uploadImage', async (ctx) => {
  const { file } = ctx.request.files;
  const fileUrl = '/temp_images/' + file.originalFilename
  ctx.body = {
    code: 200,
    data: {
      filename: file.originalFilename,
      path: fileUrl,
      //src:  `${serviceUrl}:${port}${fileUrl}`,
      src:  fileUrl,
      alt: file.originalFilename,
      url: `${serviceUrl}:${port}`,
    },
    message: 'Success',
    errorCode: 0
  }
})

module.exports = router